package com.sxt.bus.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.sxt.bus.domain.Customer;
import com.sxt.bus.mapper.CustomerMapper;
import com.sxt.bus.service.CustomerService;
import com.sxt.bus.vo.CustomerVo;
import com.sxt.bus.vo.tjfx.Pie;
import com.sxt.sys.utils.DataGridView;

@Service
@Transactional
public class CustomerServiceImpl implements CustomerService {
	@Autowired
	private CustomerMapper customerMapper;

	@Override
	public DataGridView queryAllCustomer(CustomerVo customerVo) {
		Page<Object> page = PageHelper.startPage(customerVo.getPage(),
				customerVo.getRows());
		List<Customer> list = this.customerMapper.queryAllCustomer(customerVo);
		System.out.println(page.getTotal());
		System.out.println(list.size());
		
	
		return new DataGridView(page.getTotal(), list);
	}

	@Override
	public void addCustomer(CustomerVo customerVo) {
		// TODO Auto-generated method stub
		customerMapper.insertSelective(customerVo);
	}

	@Override
	public void updateCustomer(CustomerVo customerVo) {
		// TODO Auto-generated method stub
		customerMapper.updateByPrimaryKeySelective(customerVo);
	}

	@Override
	public void deleteCustomer(CustomerVo customerVo) {
		// TODO Auto-generated method stub
		customerMapper.deleteByPrimaryKey(customerVo.getIdentity());
	}

	@Override
	public Customer selectByPrimaryKey(String identity) {
		return  this.customerMapper.selectByPrimaryKey(identity);
	}

	@Override
	public List<Customer> queryAllCustomerForList(CustomerVo customerVo) {
		// TODO Auto-generated method stub
		return this.customerMapper.queryAllCustomer(customerVo);
	}

	@Override
	public List<Pie> queryCustomerAddressCount() {
		// TODO Auto-generated method stub
		return customerMapper.queryCustomerAddressCount();
	}

	@Override
	public List<Pie> queryCustomerSex() {
		// TODO Auto-generated method stub
		return customerMapper.queryAllCustomerSex();
	}



	
}
